package top.lshaci.learning.jvm.gc;

import java.util.ArrayList;
import java.util.List;

/**
 * HeapOOm
 *
 * @author lshaci
 * @date 2020/7/30 15:28
 * @since 1.0.0
 */
public class HeapOOm {

    byte[] buffer = new byte[1 * 1024 * 1024];

    /**
     * -Xms8m -Xmx8m -XX:+HeapDumpOnOutOfMemoryError
     */
    public static void main(String[] args) {
        List<HeapOOm> list = new ArrayList<>();
        int count = 0;
        try {
         while(true) {
             list.add(new HeapOOm());
             count++;
         }
        } catch (Throwable e) {
            System.err.println("count = " + count);
            e.printStackTrace();
        }
    }
}
